@rsum function
The @rsum function is part of UCE and was introduced to facilitate Installed Capacity (ICAP) calculations but can be leveraged for other use cases. This function works by summing up register reading values from register channels or from the specified configuration group. For each channel, it selects one reading and then provides the combined total as a single scalar value.
The @rsum function is specifically designed to operate on a set of register service point channels. It returns a single scalar value, which is the sum of the register reading values from the specified service point channels. The syntax for @rsum contains the following parameters:
-
@rsum(spc1, spc2, spc3, … [, CalculationMode] [\ Exclude statuses])
-
@rsum($group:Config_Group_Id [(group parameters)] [, CalculationMode] [\ Exclude statuses])
Where:
-
spc1, spc2, spc3 represent individual Register SPCs.
-
Config_Group_Id identifies a configuration group that can be resolved into a list of Register SPCs.
-
CalculationMode is an optional parameter that determines which reading to select as the "best" when multiple readings exist in the requested period.
-
0 represents the reading with the highest Reading Group Alternate Key. If multiple readings share the same maximum Reading Group Alternate Key, the one with the highest data value is selected. This is the default value and can be omitted.
-
1 represents the peak (maximum) reading.
-
2 represents the reading with the latest EndTime.
-
3 represents the reading with the latest EndTime, searching not only in the requested time span but up to one year backward.
This flexible syntax allows @rsum to work either with an explicit list of service point channels or with a configuration group, supporting advanced calculation modes to select the most appropriate reading from each channel.
Examples:
-
($group:CAEastEnrollmentGroup1 \ POWER, ALARM) Returns the sum of the register readings from the channels that configuration group CAEastEnrollmentGroup1 includes, excluding the readings that have POWER or ALARM status and using the last received reading from each channel.
-
($group:CAEastEnrollmentGroup1 \ POWER, ALARM) Returns the sum of the register readings from the channels that configuration group RegChannelsGroup1 includes when the dynamic parameter &spid is SPTotal*, using the reading with the last EndTime from each channel.
-
($group:RegChannelsGroup1(&spid=SPTotal*), 2) Returns the sum of the register readings from the channels that configuration group RegChannelsGroup1 includes when the dynamic parameter &spid is SPTotal*, using the reading with the last EndTime from each channel.
-
($group:RegChannelsGroup2, 3) (with requested time span 4/1/2025 00:00 – 4/2/2025 00:00) Returns the sum of the register readings from the channels that configuration group RegChannelsGroup2 includes, using the reading with the last EndTime from each channel and searching for register readings in the period 4/2/2024 00:00 - 4/2/2025 00:00.
How @rsum function calculations are performed
All available register readings, within the specified time, for each service point channel are fetched. Each reading is then converted to the requested target unit of measure (UOM).
When multiple readings exist for a service point channel in the requested period, the appropriate reading is selected based on the CalculationMode parameter. For ICAP calculations, the last received reading is chosen, identified by the largest ReadingGroupAlternateKey. In other scenarios, CalculationMode can be set to select the peak (maximum) value, the reading with the latest EndTime, or the latest reading within a backward search period of up to one year.
If no readings are found for a service point channel during the requested period, an EMPTYCONTRIBUTOR status is assigned to that service point channel. After selection, the process sums up the values of the chosen readings from all service point channels and determines a combined status derived from the individual reading statuses.
Related topics: